import { SafeAreaView, StyleSheet, Switch } from 'react-native';
import { useState } from 'react';
import { ThemeContext } from './src/context/ThemeContext';
import { MyColors } from './src/styles/MyColors';
import TodoList from './src/components/TodoList';

export default function App() {
  const [theme, setTheme] = useState("light");
  return (
    <ThemeContext.Provider value={theme}>
      <SafeAreaView style={theme === "light" ? styles.container : [styles.container, { backgroundColor: MyColors.dark }]}>
        <Switch
          value={theme === "light"}
          onValueChange={() => setTheme(theme === "light" ? "dark" : "light")}
        />
        <TodoList />
      </SafeAreaView>
    </ThemeContext.Provider>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: MyColors.light,
    alignItems: 'center',
    justifyContent: 'flex-start',
  },
});
